<?php

namespace Roles;

use Roles\Model\Perfil;
use Roles\Model\PerfilTable;
use Roles\Model\Permiso;
use Roles\Model\PermisoTable;
use Roles\Model\PerfilXPermiso;
use Roles\Model\PerfilXPermisoTable;
use Roles\Model\UsuarioXPerfil;
use Roles\Model\UsuarioXPerfilTable;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;

//use Zend\ModuleManager\Feature\AutoloaderProviderInterface;

//class Module implements AutoloaderProviderInterface {
class Module {

   public function getAutoloaderConfig() {
      return array(
         'Zend\Loader\ClassMapAutoloader' => array(
            __DIR__ . '/autoload_classmap.php',
         ),
         'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
               __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
            ),
         ),
      );
   }

   public function getConfig() {
      return include __DIR__ . '/config/module.config.php';
   }

   public function getServiceConfig() {
      return array(

         'factories' => array(
            'Roles\Model\PerfilTable' => function($sm) {
               //$tableGateway = $sm->get('PerfilTableGateway');
               //$table = new PerfilTable($tableGateway);
               $table = new PerfilTable();
               return $table;
            },
            /*'PerfilTableGateway' => function($sm) {
               $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
               $resultSetPrototype = new ResultSet();
               $resultSetPrototype->setArrayObjectPrototype(new Perfil());
               return new TableGateway('perfiles', $dbAdapter, null, $resultSetPrototype);
            },*/

            'Roles\Model\PermisoTable' => function($sm) {
               //$tableGateway = $sm->get('PermisoTableGateway');
               //$table = new PermisoTable($tableGateway);
               $table = new PermisoTable();
               return $table;
            },
            /*'PermisoTableGateway' => function($sm) {
               $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
               $resultSetPrototype = new ResultSet();
               $resultSetPrototype->setArrayObjectPrototype(new Permiso());
               return new TableGateway('permisos', $dbAdapter, null, $resultSetPrototype);
            },*/

            'Roles\Model\PerfilXPermisoTable' => function($sm) {
               //$tableGateway = $sm->get('PerfilXPermisoTableGateway');
               //$table = new PerfilXPermisoTable($tableGateway);
               $table = new PerfilXPermisoTable();
               return $table;
            },
            /*'PerfilXPermisoTableGateway' => function($sm) {
               $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
               $resultSetPrototype = new ResultSet();
               $resultSetPrototype->setArrayObjectPrototype(new PerfilXPermiso());
               return new TableGateway('perfil_permiso', $dbAdapter, null, $resultSetPrototype);
            },*/

           'Roles\Model\UsuarioXPerfilTable' => function($sm) {
               //$tableGateway = $sm->get('UsuarioXPerfilTableGateway');
               //$table = new UsuarioXPerfilTable($tableGateway);
               $table = new UsuarioXPerfilTable();
               return $table;
            },
            /*'UsuarioXPerfilTableGateway' => function($sm) {
               $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
               $resultSetPrototype = new ResultSet();
               $resultSetPrototype->setArrayObjectPrototype(new UsuarioXPerfil());
               return new TableGateway('usuario_perfil', $dbAdapter, null, $resultSetPrototype);
            },*/

         ),
      );
   }

}
